﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lypshare.Net.Client;
using Lypshare.Net;

namespace Lypshare.Flow
{
	/// <summary>
	/// Interface flow client.
	/// </summary>
    public interface IFlowClient
    {
        // --------------------------------------------------------
        // Interface Events
        // --------------------------------------------------------


        /// <summary>
        /// Occurs when data received.
        /// </summary>
        event Action<IFlowClient, DataEventArgs> DataReceived ;


        /// <summary>
        /// Occurs when data sent.
        /// </summary>
        event Action<IFlowClient, DataEventArgs> DataSent;


        /// <summary>
        /// Occurs when speed changed.
        /// </summary>
        event Action<IFlowClient> SpeedChanged;


        /// <summary>
        /// Occurs when synchronized.
        /// </summary>
        event Action<IFlowClient> Synchronized;


        /// <summary>
        /// Occurs when closing.
        /// </summary>
        event Action<IFlowClient> Closing;


        /// <summary>
        /// Occurs when closed.
        /// </summary>
        event Action<IFlowClient> Closed;


        // --------------------------------------------------------
        // Interface Properties
        // --------------------------------------------------------


        /// <summary>
        /// Gets the identifier.
        /// </summary>
        /// <value>
        /// The identifier.
        /// </value>
        int Id { get; }


        /// <summary>
        /// Gets the endpoint.
        /// </summary>
        /// <value>
        /// The endpoint.
        /// </value>
        FlowEndPoint Endpoint { get; }


        /// <summary>
        /// Gets the state.
        /// </summary>
        /// <value>
        /// The state.
        /// </value>
        FlowClientState State { get; }


        /// <summary>
        /// Gets the download speed.
        /// </summary>
        /// <value>
        /// The download speed.
        /// </value>
        long DownloadSpeed { get; }


        /// <summary>
        /// Gets the upload speed.
        /// </summary>
        /// <value>
        /// The upload speed.
        /// </value>
        long UploadSpeed { get; }


        // --------------------------------------------------------
        // Interface Functions
        // --------------------------------------------------------


        /// <summary>
        /// Send the specified packet.
        /// </summary>
        /// <param name='packet'>
        /// Packet.
        /// </param>
        void Send(Packet packet);


        /// <summary>
        /// Connect the specified endpoint.
        /// </summary>
        /// <param name='endpoint'>
        /// Endpoint.
        /// </param>
        void Connect(FlowEndPoint endpoint);


        /// <summary>
        /// Close this instance.
        /// </summary>
        void Close();

    } // interface IFlowClient
} // namespace Lypshare.Flow